from typing import List


class Solution:
    """
    定义一个数组，dp[i] 为 0到i位置的最大乘积
    dp[i] = max(dp[i], dp[i]*dp[i-1])
    """

    def maxProduct(self, nums: List[int]) -> int:
        if not nums:
            return 0
        dp = []
        dp.append(nums[0])

        for i in range(1, len(nums)):
            dp.append(max(nums[i], nums[i] * dp[i-1]))
        return max(dp)


def test1():
    l = [2, 3, -2, 4]
    assert Solution().maxProduct(l) == 6


def test_empty():
    l = []
    assert Solution().maxProduct(l) == 0
